package com.authine.cloudpivot.web.api.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.authine.cloudpivot.engine.api.facade.TaskReportFacade;
import com.authine.cloudpivot.web.api.controller.base.BaseController;
import com.authine.cloudpivot.web.api.service.AsyncDataService;
import com.authine.cloudpivot.web.api.vo.MoveSubject;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: zyj
 * @time: 2021/6/17 16:00
 */
@RestController
@RequestMapping("/api/taskReport")
@Slf4j
public class TaskReportController extends BaseController {

    @Reference(version = "1.00")
    private TaskReportFacade taskReportFacade;

    @Autowired
    private AsyncDataService asyncDataService;


    @GetMapping({"/getXiaFaDataLejuan"})
    @ApiOperation(value = "QC项目任务报表",notes = "QC项目任务报表")
    @ResponseBody
    public Boolean getXiaFaDataLejuan() {
        asyncDataService.getXiaFaDataLejuanAsync();
        return true;
    }

    @PostMapping({"/moveSubject"})
    @ApiOperation(value = "更换项目经理",notes = "更换项目经理")
    @ResponseBody
    public Boolean moveSubject(@RequestBody MoveSubject subject) {
        String newUserId = subject.getNewUserId().get(0).getId();
        String oldUserId = subject.getOldUserId().get(0).getId();
        String subjectId = subject.getSubjectId();
        return taskReportFacade.moveSubject(oldUserId,newUserId,subjectId);
    }

    @GetMapping({"/createZiJianQCReport"})
    @ApiOperation(value = "自建QC项目任务报表",notes = "自建QC项目任务报表")
    @ResponseBody
    public Boolean createZiJianQCReport() {
        asyncDataService.createZiJianQCReportAsync();
        return true;
    }

    @GetMapping({"/updateSampleList"})
    @ApiOperation(value = "自建QC样本修改",notes = "自建QC样本修改")
    @ResponseBody
    public Boolean updateSampleList() {
        asyncDataService.updateSampleList();
        return true;
    }
}
